﻿@using Orchard.Search.ViewModels
@model SearchSettingsFieldsViewModel
@{
    Style.Include("orchard-search-admin.css");
}
<fieldset>
    <div class="form-group">
        @if (Model.Entries != null && Model.Entries.Any()) {
            <label>@T("Fields")</label>
            <ul class="search-indexes group">
                @{
                    var indexes = Model.Entries.Select(x => x.Index);
                    var entryIndex = 0;
                    foreach (var index in indexes) {
                        var fieldEntries = Model.Entries.Single(x => x.Index == index).Fields;
                        var entryIndexClosure = entryIndex;
                        @Html.HiddenFor(m => m.Entries[entryIndex].Index)
                        <li>
                            <h3>@index</h3>
                            <ul>
                                @{ var fieldIndex = 0; }
                                @foreach (var fieldEntry in fieldEntries) {
                                    var fieldIndexClosure = fieldIndex;
                                    <li>
                                        @Html.EditorFor(m => m.Entries[entryIndex].Fields[fieldIndex].Selected)
                                        @Html.HiddenFor(m => m.Entries[entryIndex].Fields[fieldIndex].Field)
                                        <label class="forcheckbox" for="@Html.FieldIdFor(m => m.Entries[entryIndexClosure].Fields[fieldIndexClosure].Selected)">@Model.Entries[entryIndex].Fields[fieldIndex].Field</label>
                                    </li>
                                    fieldIndex++;
                                }
                            </ul>
                        </li>
                        entryIndex++;
                    }
                }
            </ul>
            <span class="hint">@T("Check any field for each index which should be used for search queries.")</span>

        }
    </div>
    <div>
        <label>@T("Localization")</label>
        @Html.EditorFor(m => m.FilterCulture)
        <label class="forcheckbox" for="@Html.FieldIdFor(m => m.FilterCulture)">@T("Narrow search to current culture only")</label>
        <span class="hint">@T("If checked, search results will only include content items localized in the current culture of the request.")</span>
    </div>
    <div>
        <label for="@Html.FieldIdFor(m => m.DisplayType)">@T("Display Type")</label>
        @Html.TextBoxFor(m => m.DisplayType, new { @class = "text single-line" })
        <span class="hint">@T("The display type to use for content items in the search results page.")</span>
    </div>
</fieldset>